/*
Correcting Misinformation About Climate Change: The Impact of Partisanship in an Experimental Setting (forthcoming at Climatic Change)
Replication commands for tables and figures in manuscript

Authors:	Salil D. Benegal and Lyle A. Scruggs | 03.25.2018

The data uploaded here were obtained from a single survey conducted on Amazon Mechanical Turk. 
These are the original (i.e. uncleaned) data, which include incomplete/potentially non-attentive responses.
This file contains commands to clean/recode data and run the analyses for the tables and figures in our study.
The full wording of treatments and survey questions are detailed in the file Survey.pdf.

Please contact the corresponding author at salilbenegal at depauw.edu for any questions or comments pertaining to these data.

All commands/functions pertain to the file use "Replication data.dta".

*/

/*PID3 is 1=Rep 2= Dem 3=Ind, third party ids are coded missing*/

/* The combined treatments counter is 1=control (misinfo with no correction), 2=Democrat correction, 3=Expert correction, 4=Republican correction*/


***********************************************
*** Commands for data cleaning/organization ***
***********************************************

// Exclude respondents if they did not finish or failed attention check

drop if V10==0
drop if attention==2

// Generate treatment variable

gen treatments=.
replace treatments=0 if DO=="Q2"
replace treatments=1 if DO=="Q8"
replace treatments=2 if DO=="Q9"
replace treatments=3 if DO=="Q10"

label define treatments 0 "No correction" 1 "Democrat correction" 2 "Expert correction" 3 "Republican correction"
label values treatments treatments
label var treatments "Experimental treatment"
tab treatments, m
tab treatments DO
tab treatments, gen(cond)

// Generate party ID measures

gen partyid=.
replace partyid=1 if pid==1 & missing(partyid)
replace partyid=1 if partyln==1 & missing(partyid)
replace partyid=2 if pid==2 & missing(partyid)
replace partyid=2 if partyln==2 & missing(partyid)
replace partyid=3 if pid==3 & missing(partyid)

label define partyid 1 "Republican" 2 "Democrat" 3 "Independent"
label values partyid partyid
label variable partyid "Partisanship"

gen pid3=pid if pid<4
replace pid3=3 if pid==4

recode age (min/30=1) (31/45=2) (46/64=3) (65/max=4), gen(age_cat)
gen norelig=(inlist(religion,10,11))

// 3 point PID scale but with leaners
gen pid3wl=pid3
replace pid3wl=1 if pid3==3 & partyln==1
replace pid3wl=2 if pid3==3 & partyln==2

label define pid3values 1 "Repub." 2 "Democrat" 3 "Indepen"
label val pid3 pid3values
label val pid3wl pid3values

/* 7 point ID strength, with all but 3rd prty no Dem/Rep preference*/
gen pidwstr=1 if pid==1 & repstr==1
replace pidwstr=2 if pid==1 & repstr==2
replace pidwstr=7 if pid==2 & demstr==1
replace pidwstr=6 if pid==2 & demstr==2
replace pidwstr=3 if (pid>2 & pid<6) & partyln==1
replace pidwstr=5 if (pid>2 & pid<6) & partyln==2
replace pidwstr=4 if (pid==3 | pid==4) & partyln==3
label define pid7values 1 "Str. Rep" 2 "Mod. Rep" 3 "Ind., Rep" 4 "Ind" 5"Ind., Dem" 6 "Mod. Dem." 7 "Str. Dem."
label val pidwstr pid7values

// other covariates

gen male=.
replace male=0 if missing(sex)
replace male=1 if sex==1

gen educ2=0 if !missing(educ)
replace educ2=1 if educ<4
replace educ2=2 if educ==4
replace educ2=2 if educ==5
replace educ2=3 if educ==6
replace educ2=4 if educ==7

label define educ2 1 "High school or less" 2 "Some college" 3 "College degree" 4 "Postgrad education"
label values educ2 educ2
label variable educ2 "Education (recoded)"

gen r_white=. 
replace r_white=0 if missing(race)
replace r_white=1 if race==1

gen vconservative=.
replace vconservative=0 if missing(ideo)
replace vconservative=1 if ideo==1
gen conservative=.
replace conservative=0 if missing(ideo)
replace conservative=1 if ideo==2
gen moderate=.
replace moderate=0 if missing(ideo)
replace moderate=1 if ideo==3
gen liberal=.
replace liberal=0 if missing(ideo)
replace liberal=1 if ideo==4
gen vliberal=.
replace vliberal=0 if missing(ideo)
replace vliberal=1 if ideo==5

gen highschool=.
replace highschool=0 if missing(educ2)
replace highschool=1 if educ2==1
gen somecoll=.
replace somecoll=0 if missing(educ2)
replace somecoll=1 if educ2==2
gen college=.
replace college=0 if missing(educ2)
replace college=1 if educ2==3
gen postgrad=.
replace postgrad=0 if missing(educ2)
replace postgrad=1 if educ2==4

label var highschool "High school or less"
label var somecoll "Some college (no 4 yr degree)"
label var college "College degree"
label var postgrad "Postgraduate degree"

recode highschool(.=0) if !missing(educ)
recode somecoll(.=0) if !missing(educ)
recode college(.=0) if !missing(educ)
recode postgrad(.=0) if !missing(educ)

recode vconservative(.=0) if !missing(ideo)
recode conservative(.=0) if !missing(ideo)
recode moderate(.=0) if !missing(ideo)
recode liberal(.=0) if !missing(ideo)
recode vliberal(.=0) if !missing(ideo)

recode r_white(.=0) if !missing(race)
recode male(.=0) if !missing(sex)

label variable male "Male"
label variable r_white "Race: White"
label variable vconservative "Very conserative"
label variable conservative "Conservative"
label variable moderate "Moderate"
label variable liberal "Liberal"
label variable vliberal "Very liberal"


**********************************************************
*** Commands to replicate tables/figures in manuscript ***
**********************************************************


/*means for treatment by political party id*/
table treatments pid3wl, c(mean CCbelief mean CChumans mean CCserious)
 

/*Regression table*/
// Model 1
reg CCb  pid3wl##treatments, rob
// Model 2
reg CCb pid3wl##treatments i.age_cat vcons cons lib vlib highschool somecoll postgrad r_white i.newsattn male norel, rob
// Model 3
reg CCh  pid3wl##treatments, rob
// Model 4
reg CCh pid3wl##treatments i.age_cat vcons cons lib vlib highschool somecoll postgrad r_white i.newsattn male norel, rob
// Model 5
reg CCs  pid3wl##treatments, rob
// Model 6
reg CCs pid3wl##treatments i.age_cat vcons cons lib vlib highschool somecoll postgrad r_white i.newsattn male norel, rob
eststo

/*NEW Figure 1 Difference of means from control  (3 Question * 3 source corrctions) */

qui reg CCbelief i.treatments
estimates store b

qui reg CChuman i.treatments
estimates store h

qui reg CCser i.treatments
estimates store s 

coefplot (b, label(Scientific Consensus) ms(X)) (h, label(Human cause) ms(O))  (s, label(Important Problem) ms(Oh)) ,drop(_cons) xline(0, lpattern(dash)) xtitle(differences vs. control group) legend(size(small)) byopts(xrescale)  
*/

/*Figure for Difference of means relative to control group by partyid and treatment*/
/*CC belief*/
qui reg CCbelief i.treatments if pid3wl==1
estimates store breps
qui reg CCbelief i.treatments if pid3wl==2
estimates store bdems
qui reg CCbelief i.treatments if pid3wl==3
estimates store binds

/*CC human attribution*/
qui reg CChuman i.treatments if pid3wl==1
estimates store hreps
qui reg CChum i.treatments if pid3wl==2
estimates store hdems
qui reg CChum i.treatments if pid3wl==3
estimates store hinds

/*CC serious*/
qui reg CCser i.treatments if pid3wl==1
estimates store sreps
qui reg CCser i.treatments if pid3wl==2
estimates store sdems
qui reg CCser i.treatments if pid3wl==3
estimates store sinds

coefplot (bdems, label(Dem Respondents) ms(X)) (breps, label(Repub Respondents) ms(O))  (binds, label(Ind Respondents) ms(Oh)), bylabel(Scientific Consensus) ///
||(hdems, label(Dem Respondents)) (hreps, label(Repub Respondents))  (hinds, label(Ind Respondents)), bylabel(Human Cause) ///
|| (sdems, label(Dem Respondents)) (sreps, label(Repub Respondents))  (sinds, label(Ind Respondents)), bylabel(Important Problem) ///
|| ,drop(_cons) xline(0, lpattern(dash))   byopts(xrescale) legend(size(small)) xtitle(differences vs. control group)

